package MicroGZM.mesh;

import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;

public class Cube extends Mesh
{
	public Cube()
	{       
//	    drawMode = GL11.GL_TRIANGLES;
//
//	    totalVertices = 6 * 4;
	    
	    testSet();

//	    FloatBuffer vertices = BufferUtils.createFloatBuffer(totalVertices * 3);
//	    IntBuffer indices = BufferUtils.createIntBuffer(totalVertices);
//	    for(float x = -0.5F; x < 1; x++) for(float y = -0.5F; y < 1; y++) for(float z = -0.5F; z < 1; z++)
//	    {
//	        vertices.put(new float[]{x, y, z});
//	    }
//	    
//	    int[] a = {0, 1, 2, 3, 4, 5, 6, 7};
//	    int[] b = {0, 1, 4, 5, 2, 3, 6, 7};
//	    int[] c = {0, 2, 4, 6, 1, 3, 5, 7};
//
//	    indices.put(a);
//	    indices.put(b);
//	    indices.put(c);
//	    
//	    vertices.position(0);
//	    indices.position(0);
//
//	    vertexBufferID = createVBOID();
//	    bufferData(vertexBufferID, vertices);
////
//	    indexBufferID = createVBOID();
//	    bufferElementData(indexBufferID, indices);
	}

	private void testSet()
	{
		float verts[] = new float[]
		{
				-0.5f, -0.5f, 0.5f,
				0.5f, -0.5f, 0.5f,
				-0.5f, 0.5f, 0.5f,
				0.5f, 0.5f, 0.5f,
				-0.5f, 0.5f, -0.5f,
				0.5f, 0.5f, -0.5f,
				-0.5f, -0.5f, -0.5f,
				0.5f, -0.5f, -0.5f,
		};
		int inds[] = new int[]
		{
			0,1,2,
			2,1,3,
			2,3,4,
			4,3,5,
			4,5,6,
			6,5,7,
			6,7,0,
			0,7,1,
			1,7,3,
			3,7,5,
			6,0,4,
			4,0,2,
		};

		
		FloatBuffer vertices = BufferUtils.createFloatBuffer(verts.length);
	    IntBuffer indices = BufferUtils.createIntBuffer(inds.length);
		
		for(int i = 0; i < verts.length; i++)
	    {
	        vertices.put(verts[i]);
	    }
		
		for(int i = 0; i < inds.length; i++)
	    {
			indices.put(inds[i]);
	    }
	    
	    vertices.position(0);
	    indices.position(0);

//	    vertexBufferID = createVBOID();
//	    bufferData(vertexBufferID, vertices);
//
//	    indexBufferID = createVBOID();
//	    bufferElementData(indexBufferID, indices);
		
	}	

}
